
@interface MMUIViewController : UIViewController
{
    UINavigationController *m_navigationController;
}
@end

@interface CMessageWrap:NSObject
{
    NSString *m_nsContent;
    unsigned int m_uiMessageType;
}
@property(retain, nonatomic) NSString *m_nsContent;
+ (id)getMsgImg:(id)arg1;
+ (id)getMaskedVideoMsgImgThumb:(id)arg1;

- (_Bool)IsImgMsg;
- (_Bool)IsTextMsg;
@end

@protocol messageNodeViewDelegate <NSObject>
- (MMUIViewController *)getViewController;
@end

@interface BaseMessageNodeView : NSObject
{
    CMessageWrap *m_oMessageWrap;
    id <messageNodeViewDelegate> m_delegate;
}
- (id)m_msgWrap;
@end

@interface MMTextView : NSObject
{

}
- (void)setText:(id)arg1;
@end

@interface MMGrowTextView : NSObject
{
    MMTextView *_textView;
}
- (void)postTextChangeNotification;
@end

@interface WCNewCommitViewController:MMUIViewController
{
    MMGrowTextView *_textView;
}
@property(nonatomic) _Bool bCommmitOnlyText;
- (id)initWithImages:(id)arg1 contacts:(id)arg2;
- (void)OnDone;
@end

@interface SightMomentEditViewController : MMUIViewController
{
    NSString *_realMoviePath;
    NSString *_moviePath;
    UIImage *_thumbImage;
    UIImage *_realThumbImage;
}
@property(nonatomic) _Bool directClose;
@property(nonatomic) _Bool fromDraft;
@property(retain, nonatomic) NSString *moviePath;
@property(retain, nonatomic) NSString *realMoviePath;
@property(retain, nonatomic) UIImage *realThumbImage;
@property(retain, nonatomic) UIImage *thumbImage;
- (id)init;
@end

@interface ImageMessageNodeView : BaseMessageNodeView
{}
- (void)onForward:(id)arg1;
@end

@interface MMImage : NSObject
{}
- (id)initWithImage:(id)arg1;
- (void)commonInit;
@end


@interface TextMessageNodeView : BaseMessageNodeView
{}
- (void)onForward:(id)arg1;
@end

@interface VideoMessageNodeView : BaseMessageNodeView
{
    NSString *m_videoPath;
}
- (id)getCoverImage;
- (id)getMessageImageView;
- (id)thumbImage;
- (void)onForward:(id)arg1;
@end


int sharetext = 0;
NSString *sharemsg = @"";

%hook ImageMessageNodeView
- (void)onForward:(id)arg1{
    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];
    UIImage *uimage = [%c(CMessageWrap) getMsgImg: MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap")];
    MMImage *mmimage = [[%c(MMImage) alloc] initWithImage:uimage];
    [mmimage commonInit];
    NSMutableArray* array = [[NSMutableArray alloc] initWithObjects:mmimage, nil];
    WCNewCommitViewController *wcvc = [[%c(WCNewCommitViewController) alloc] initWithImages:array contacts:nil];
    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];
    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
}

%new(v@:@)
- (void)sharetotimeline{
    UIImage *uimage = [%c(CMessageWrap) getMsgImg: MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap")];
    MMImage *mmimage = [[%c(MMImage) alloc] initWithImage:uimage];
    [mmimage commonInit];
    NSMutableArray* array = [[NSMutableArray alloc] initWithObjects:mmimage, nil];

    WCNewCommitViewController *wcvc = [[%c(WCNewCommitViewController) alloc] initWithImages:array contacts:nil];

    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];

    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];
    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
}
%end



%hook TextMessageNodeView
- (void)onForward:(id)arg1{
    %log;
    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];
    CMessageWrap *msgwrap = MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap");
    NSString *msgtext =[msgwrap m_nsContent];
    sharemsg = msgtext;
    sharetext = 1;
    WCNewCommitViewController *wcvc = [[%c(WCNewCommitViewController) alloc] initWithImages:nil contacts:nil];
    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];
    [wcvc setBCommmitOnlyText:1];
    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
}

%new(v@:@)
- (void)sharetotimeline{
    %log;

    CMessageWrap *msgwrap = MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap");
    NSString *msgtext =[msgwrap m_nsContent];
    sharemsg = msgtext;
    sharetext = 1;

    WCNewCommitViewController *wcvc = [[%c(WCNewCommitViewController) alloc] initWithImages:nil contacts:nil];

    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];
    [wcvc setBCommmitOnlyText:1];

    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];

    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
}



%end

%hook VideoMessageNodeView
- (void)onForward:(id)arg1{
    %log;
    SightMomentEditViewController *wcvc = [[%c(SightMomentEditViewController) alloc] init];
    NSLog(@"============all oc init here");
    NSString *vpath=MSHookIvar<NSString *>(self,"m_videoPath");
    NSLog(@"====video path%@",vpath);
    [wcvc setMoviePath:vpath];
    [wcvc setRealMoviePath:vpath];
    [wcvc setThumbImage:[%c(CMessageWrap) getMaskedVideoMsgImgThumb: MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap")]];
    [wcvc setRealThumbImage: [%c(CMessageWrap) getMaskedVideoMsgImgThumb: MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap")]];
    [wcvc setFromDraft:1];
    [wcvc setDirectClose:1];
    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];
    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];
    NSLog(@"===%@",vc);
    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
}
%end


%hook WCNewCommitViewController
- (id)initWithImages:(id)arg1 contacts:(id)arg2{
    NSLog(@"==%@",arg1);
    %log;
    return %orig;
}

- (void)viewDidAppear:(_Bool)arg1{
    if(sharetext){
        MMGrowTextView *grow = MSHookIvar<MMGrowTextView *>(self,"_textView");
        MMTextView *mmtext = MSHookIvar<MMTextView *>(grow,"_textView");
        [mmtext setText:sharemsg];
        [grow postTextChangeNotification];
        sharemsg = @"";
        sharetext = 0;
    }
}
%end

%hook BaseMessageNodeView
- (void)showOperationMenu:(id)arg1 NeedDelete:(_Bool)arg2 {
    NSLog(@"=======%s",object_getClassName(self));
    CMessageWrap *mw = [self m_msgWrap];
    if([mw IsTextMsg] || [mw IsImgMsg]){
        NSMutableArray *menuarray = [[NSMutableArray alloc]initWithArray:arg1];
        UIMenuItem *menu_timeline = [[UIMenuItem alloc] initWithTitle:@"朋友圈" action:@selector(sharetotimeline)];
        [menuarray insertObject:menu_timeline atIndex:0];
        [menu_timeline release];
        %orig(menuarray,arg2);
    }else{
        %orig;
    }
}
%end
